package demo11;

public class Test01 {
    public static void main(String[] args) {
        String[][] all = {
                {"张三","37","89","5"},
                {"李四","95","41","79"},
                {"王五","60","84","29"},
                {"赵六","87","46","86"}
        };
        printMathScore(all);
        getCountMathScore(all);
        getAvgMathScore(all);
        getAvgName(all);
        getAvgCount(all);
    }

    private static void getAvgCount(String[][]all) {
        int sum=0;
        for (String[] s : all) {
            sum+=Integer.parseInt(s[2]);
        }
        int count=0;
        int avg=sum/all.length;
        for (int i = 0; i < all.length; i++) {
            if (Integer.parseInt(all[i][2])>avg){
                count++;
            }
        }
        System.out.println(count);
    }

    private static void getAvgName(String[][]all) {
        int sum=0;
        for (String[] s : all) {
            sum+=Integer.parseInt(s[2]);
        }
        int avg=sum/all.length;
        for (int i = 0; i < all.length; i++) {
            if (Integer.parseInt(all[i][2])>avg){
                System.out.println(all[i][0]+" ");
            }
        }
        System.out.println();
    }

    private static void getAvgMathScore(String[][]all) {
        int sum=0;
        for (String[] s : all) {
            sum+=Integer.parseInt(s[2]);
        }
        int avg=sum/all.length;
        System.out.println(avg);
    }

    private static void getCountMathScore(String[][]all) {
        int sum=0;
        for (String[] s : all) {
            sum+=Integer.parseInt(s[2]);
        }
        System.out.println(sum);
    }

    private static void printMathScore(String[][]all) {
        for (String[] s : all) {
            System.out.println(s[2]);
        }
    }

}
